<!DOCTYPE html>
<html>
<head>
    <title>我的数据</title>
<#include "/common/include_header.ftl">
</head>
<body>

<#include "/common/include_top.ftl">

<div class="layui-container fly-marginTop fly-user-main">

<#include "/common/include_menu.ftl">

    <div class="site-tree-mobile layui-hide">
        <i class="layui-icon">&#xe602;</i>
    </div>
    <div class="site-mobile-shade"></div>

    <div class="site-tree-mobile layui-hide">
        <i class="layui-icon">&#xe602;</i>
    </div>
    <div class="site-mobile-shade"></div>


    <div class="fly-panel fly-panel-user" pad20>


        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>创建我的数据</legend>
        </fieldset>


        <div class="layui-form"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
            <div class="layui-form-item">
                <label class="layui-form-label">数据标题</label>
                <div class="layui-input-block">
                    <input  id="title" type="text" name="" placeholder="请输入" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">数据类型</label>
                <div class="layui-input-block">
                    <select id="type" name="interest" lay-filter="aihao">
                        <option value=""></option>
                        <option value="0">表格</option>
                        <option value="1">json</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">对外展示</label>
                <div class="layui-input-block">
                    <input id="isShow" type="checkbox" lay-text="展示|私人" lay-skin="switch">
                    <#--<input type="checkbox" checked lay-skin="switch">-->
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">数据说明</label>
                <div class="layui-input-block">
                    <textarea id="intro" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button onclick="submint()" class="layui-btn"  lay-filter="*">立即提交</button>
                    <#--<button class="layui-btn" lay-submit lay-filter="*">立即提交</button>-->
                    <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                </div>
            </div>
            <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
        </div>

        <script>
            function submint() {
                var title = $("#title").val();
                var type = $("#type").val();
                var isShow = $("#isShow").is(':checked');
                var intro = $("#intro").val();

                if (hasNull(title, type)) {
                    layer.msg('存在空数据', {icon: 2});
                } else {
                    var isShowNum = 0;
                    if (isShow)
                        isShowNum = 1
                    $.ajax({
                    <#--url: '${basePath}/data/doSave',-->
                        url: '/data/doSave',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            title: title,
                            type: type,
                            isShow: isShowNum,
                            intro: intro
                        },
                        success: function (rd) {
                            var dataId = rd.data.id;
                            if (rd.suc) {
                                window.location.href = "${basePath}/data/" + dataId + "/info";
                            } else {
                                layer.msg(rd.msg, {icon: 2});
                            }
                        }
                    });
                }
            }

        </script>
    </div>
</div>





<#include "/common/include_footer.ftl">
<#include "/common/include_js.ftl">
</body>
</html>